package com.wenli.graduate2022.wenliGreenShop.controller;

import com.wenli.graduate2022.wenliGreenShop.entity.Review;
import com.wenli.graduate2022.wenliGreenShop.service.servDao.ReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author HuangHai
 * @date 2021/10/13 16:49
 */
@RestController
public class ReviewController {

    @Autowired
    ReviewService reviewService;

    @GetMapping("/review/findByUserId/{id}")
    public List<Review> findByUserId(@PathVariable("id") Integer id) {         //查询该用户所发出的所有评论
        return reviewService.findByUserId(id);
    }


    @GetMapping("review/findByProductId/{id}")
    public List<Review> findByProductId(@PathVariable("id") Integer id) {      //查询该产品下的所有留言
        return reviewService.findByProductId(id);
    }

}
